<?php
include ("../lib/DAL/SinhVien.php");

class SinhVienBLL{
    function __construct(){
    }
    
    function __destruct(){
    }
    
    function setSinhvien($row){
        $sv = new SinhVien();
        $sv->setSinhvien($row['ma_sv'],$row['hoten_sv'],$row['cmtnd_sv'],$row['ngaysinh_sv'],$row['dienthoai_sv'],$row['noisinh_sv'],$row['gioitinh_sv']);
        return $sv;
    }
    
    public function getListSinhvien(){
        $execSqlSv=mysql_query("SELECT SV.ma_sv, SV.hoten_sv, SV.cmtnd_sv, SV.ngaysinh_sv, SV.dienthoai_sv, SV.noisinh_sv, SV.gioitinh_sv FROM tbl_sinhvien AS SV WHERE 1=1 LIMIT 0, 15");
        if($execSqlSv){
            while($row=mysql_fetch_array($execSqlSv)){
                $ds[]=$this->setSinhvien($row);
            }
        }
        return $ds;
    }
    public function addSinhvien($sv){
        $sql="INSERT INTO tbl_sinhvien (ma_sv, hoten_sv, cmtnd_sv, ngaysinh_sv, dienthoai_sv, noisinh_sv, gioitinh_sv)
              VALUES('".$sv->getma_sv()."','".$sv->gethoten_sv()."','".$sv->getcmtnd_sv()."','".$sv->getngaysinh_sv()."','".$sv->getdienthoai_sv()."','".$sv->getnoisinh_sv()."','".$sv->getgioitinh_sv()."')";
        //echo $sql_sv;
        $rs=mysql_query($sql);
        return $rs;
    }
    public function delSinhvien($masv){
        $sql="DELETE FROM tbl_sinhvien WHERE ma_sv = '".$masv."'";
        $result = mysql_query($sql) or die (mysql_error());
        return $result;
    }
    
}

?>